#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
using namespace std;
int main()
{
    int count = 0;
    int n = 0;
    cin >> n;
    for (int i = 0; i <= n; i++)
    {
        int j = i;
        int i_count = 10;
        while (j /= 10)
        {
            i_count *= 10;
        }
        if (((i * i) % i_count) == i)
            count++;
    }
    cout << count;
    return 0;
}